package com.xindaoapp.henghua.protocol.model;

import org.json.JSONObject;

import com.alibaba.fastjson.JSON;
import com.loopj.android.http.RequestParams;
import com.loopj.android.http.util.MoccaRequest;
import com.loopj.android.http.util.Response.ErrorListener;
import com.loopj.android.http.util.Response.Listener;
import com.xindaoapp.henghua.entry.PropertyInfo;
import com.xindaoapp.henghua.utils.MoccaPreferences;

/**
 * 网络请求模板（设备监造）
 * 
 * @author xindaoapp
 * 
 */
public class PropertyRequest extends MoccaRequest<PropertyInfo> {

	public PropertyRequest(String url, Listener<PropertyInfo> listener, ErrorListener errorListener) {
		super(url, listener, errorListener);
	}

	@Override
	public RequestParams getRequestParams() {
		return params;
	}

	@Override
	public PropertyInfo parseNetworkResponse(String response) {
		try {
			PropertyInfo propertyInfo = JSON.parseObject(response, PropertyInfo.class);
			MoccaPreferences.PROPERTYDATASTIME.put(new JSONObject(response).getString("currentTime"));
			return propertyInfo;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
